package com.fzb.forum4j.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.fzb.forum4j.po.Blog;
import com.fzb.forum4j.service.api.IBlogService;

@Controller("blogAction")
public class BlogAction extends CommonsAction<Blog>{

	/**
	 * 博客管理 ()
	 */
	private static final long serialVersionUID = 1L;
	@Resource(name="blogServiceImpl")
	private IBlogService articleService;
	
	public String details(){
		articleService.getBlogAndComment(getQmd());
		return "details";
	}
	public String sort(){
		articleService.getBlogsBySort(getQmd());
		return "list";
	}
	public String list(){
		articleService.getList(getQmd());
		return "list"; 
	}
	@Override
	public Object getModel() {
		getQmd().setT(getT());
		getQmd().getT().setUser(getUserMsg());
		return getQmd();
	}
	public String write(){
		if(getQmd().getId()>0){
			articleService.getSimpleBlogMsgByUserAndCid(getQmd());
		}
		//如果查询到数据就继续查询blog的分类
		articleService.getBlogSortByUserName(getQmd());
		return "edit";
	}
	@Override
	public String go_edit() {
		return write();
	}
	
	public String search(){
		articleService.getBlogsByQmd(getQmd());
		return "search";
	}
	@Override
	public String add() {
		getQmd().getT().setUser(getUserMsg());
		return super.add();
	}
 
 
}
